def solve(nums):
    nums.sort()
    n = len(nums)
    res = set()
    for i in range(n):
        if i > 0 and nums[i] == nums[i - 1]:
            continue
        for j in range(i + 1, n):
            if j > i + 1 and nums[j] == nums[j - 1]:
                continue
            k = n - 1
            while k > j:
                if k < n - 1 and nums[k] == nums[k + 1]:
                    k -= 1
                    continue
                if nums[i] + nums[j] + nums[k] == 0:
                    res.add((nums[i], nums[j], nums[k]))
                k -= 1

    return [list(s) for s in res]


if __name__ == "__main__":
    nums = [-1, 0, 1, 2, -1, -4]
    print(solve(nums))
